﻿import com.dinmax.gustavoaguero.jackpot.*
import com.dinmax.flash.common.collection.*
import com.dinmax.flash.gsa.communication.parameter.*
import com.dinmax.flash.gsa.sgs.draw.spin.*

class SLOTBridgeDummy implements SpinManagerListener{
	
	private var parent:MovieClip;
	private var spManager:SpinManager;
	
	private static var instance:SLOTBridgeDummy;
	
	public static function newInstance(parent:MovieClip, serial:String):Void {
		instance= new SLOTBridgeDummy(parent, serial);
	}; //fin función

	public static function getActive():SLOTBridgeDummy{
		return instance;
	};
	
	function SLOTBridgeDummy (parent:MovieClip){
		this.parent=parent;
		this.createSpins(this);
		SLOTBridgeButtons.initButtons(parent, this);
		
	};	

	public function getParent():MovieClip {
		return parent;
	}; //fin función
		
	
	//GAMESLOT 2 SWF
		public function GAMESLOT_2_SWF_setPosition(parameters:Parameter, noRound:Boolean):Void {
			setPosition(parameters, noRound);
			parent.mcSpin._visible=true;
			parent.mcSpin2._visible=true;
			parent.mcSpin3._visible=true;
		}; //fin función
		
		public function GAMESLOT_2_SWF_win(level:Number):Void {
			marquee("win");
			lightsOn(level);
			parent.mcBack.play();
			var cont:Number=0;
			var root:SLOTBridgeDummy=this;
			parent.onEnterFrame=function(){
				if(cont==52){
					delete this.onEnterFrame;
					root.SWF_2_GAMESLOT_roundEnd(true);
					root.lightsOff();
					
				} else {
					cont++;
				};
			};
			
		}; //fin función
		

	//
	
	//SWF 2 GAMESLOT
		public function SWF_2_GAMESLOT_roundEnd(win:Boolean):Void {
			//GameSlot.getActive().roundEnd(win);
			MACHODROMO.roundEnd();
		}; //fin función

	//

	public function setPosition(position:Collection, noRound:Boolean):Void {
		spManager.setPosition(position, noRound);
	}; //fin función
	
	public function spinsRoundsEnds(id:Number):Void {
		lightsOff();
		SLOTBridgeButtons.unblockButtons(parent);
		SWF_2_GAMESLOT_roundEnd();
	}; //fin función

	public function play():Void {
		//acá le tengo que decir al GAMESLOT que haga play() con el bet que haya;
		lightsOn();
		marquee("play");
		SLOTBridgeSounds.play(parent);
		SLOTBridgeButtons.blockButtons(parent);
		MACHODROMO.play();
		
	}; //fin función
	
	private function createSpins(root:SLOTBridgeDummy):Void {
				
		parent.mcSpin.stop();
		parent.mcSpin._visible=false;
		parent.mcSpin2.stop();
		parent.mcSpin2._visible=false;
		parent.mcSpin3.stop();
		parent.mcSpin3._visible=false;
		
		var spin1:Spin= new Spin(1, parent.mcSpin);
		spin1.setFrameStep(25);

		var spin2:Spin= new Spin(2, parent.mcSpin2);
		spin2.setFrameStep(25);

		var spin3:Spin= new Spin(3, parent.mcSpin3);
		spin3.setFrameStep(25);

		spManager=new SpinManager(1);
		spManager.addListener(this);
		spManager.addSpin(spin1.getId(), spin1);
		spManager.addSpin(spin2.getId(), spin2);
		spManager.addSpin(spin3.getId(), spin3);
		
	}; //fin función
	
	private function createButtons(root:SLOTBridgeDummy){
		
	};

	private function lightsOn(level:Number):Void {
		//trace(parent.mcLights);
		if(level >= 0){
		parent.mcLights.lightsWin(level);
			
		} else {
		parent.mcLights.lightsOn();
		}
	};

	private function lightsOff():Void {
		parent.mcLights.lightsOff();
		parent.mcBack.gotoAndStop(1);
	};
	
	private function marquee(frame:String):Void{
		if (frame=="win")
		{
				SLOTBridgeSounds.win(parent);
		};

		parent.mcMarquee.gotoAndStop(frame);
	};
	

}; // fin de clase